package com.lx.mobileplayer.mvp.persenter

import com.lx.mobileplayer.mvp.model.HomeItemBean
import com.lx.mobileplayer.mvp.view.Iview.IHomeView
import com.lx.mobileplayer.net.OkHttpUtil
import com.lx.mobileplayer.net.URLProvider

/**
 * 类说明：首页的presenter
 * Created by liuxiong on 2019/4/27.
 */
class HomePresenter(view:IHomeView):BasePresenter<IHomeView>(view) {

    fun requestData(offset:Int,pageSize:Int){

        var url= URLProvider.getHomeUrl(offset,pageSize)

        OkHttpUtil.instance.request(url,object : OkHttpUtil.ResultCallBack<List<HomeItemBean>>() {
            override fun succecss(data: List<HomeItemBean>) {
                getView().loadSuccess(data as ArrayList<HomeItemBean>)
            }

            override fun failed(code: Int, errorMessage: String) {
                getView().loadFailed(code,errorMessage)
            }
        })

    }

}